package com.ruoyi.teacher.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teacher.domain.TeacherInformationDetail;
import com.ruoyi.teacher.service.ITeacherInformationDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资料信息Controller
 * 
 * @author ruoyi
 * @date 2024-07-01
 */
@RestController
@RequestMapping("/teacherInfo/detial")
public class TeacherInformationDetailController extends BaseController
{
    @Autowired
    private ITeacherInformationDetailService teacherInformationDetailService;

    /**
     * 查询资料信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:detial:list')")
    @GetMapping("/list")
    public TableDataInfo list(TeacherInformationDetail teacherInformationDetail)
    {
        startPage();
        List<TeacherInformationDetail> list = teacherInformationDetailService.selectTeacherInformationDetailList(teacherInformationDetail);
        return getDataTable(list);
    }

    /**
     * 导出资料信息列表
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:detial:export')")
    @Log(title = "资料信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TeacherInformationDetail teacherInformationDetail)
    {
        List<TeacherInformationDetail> list = teacherInformationDetailService.selectTeacherInformationDetailList(teacherInformationDetail);
        ExcelUtil<TeacherInformationDetail> util = new ExcelUtil<TeacherInformationDetail>(TeacherInformationDetail.class);
        util.exportExcel(response, list, "资料信息数据");
    }

    /**
     * 获取资料信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:detial:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(teacherInformationDetailService.selectTeacherInformationDetailById(id));
    }

    /**
     * 新增资料信息
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:detial:add')")
    @Log(title = "资料信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TeacherInformationDetail teacherInformationDetail)
    {
        Long userId= SecurityUtils.getUserId();
        teacherInformationDetail.setUserId(userId);
        teacherInformationDetail.setCreateDate(DateUtils.parseDate(DateUtils.getTime()));
        return toAjax(teacherInformationDetailService.insertTeacherInformationDetail(teacherInformationDetail));
    }

    /**
     * 修改资料信息
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:detial:edit')")
    @Log(title = "资料信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TeacherInformationDetail teacherInformationDetail)
    {
        return toAjax(teacherInformationDetailService.updateTeacherInformationDetail(teacherInformationDetail));
    }

    /**
     * 删除资料信息
     */
    @PreAuthorize("@ss.hasPermi('teacherInfo:detial:remove')")
    @Log(title = "资料信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(teacherInformationDetailService.deleteTeacherInformationDetailByIds(ids));
    }
}
